<?php

include_once ('../../utilities.php')

?>
<!DOCTYPE html>
<html>
<head>
	<link rel="stylesheet" type="text/css" href="../../reset.css">
	<link rel="stylesheet" type="text/css" href="../../mainStyle.css">
	<link rel="stylesheet" type="text/css" href="../../searchButton.css">
	<title>Password Change</title>
</head>
<body>

	<div id="container">
		<?php

$root = '../../';
include_once ('../../header.php')

?>
        
		<div id="page-body">
		<?php

if (!empty($_POST['firstname']) && !empty($_POST['lastname']) && !empty($_SESSION['LoggedIn']) &&
    !empty($_SESSION['User']))
{ //Info posted to form
    //Update their first and last name
    $user = unserialize($_SESSION['User']);
    $user->setFirstName($_POST['firstname']);
    $user->setLastName($_POST['lastname']);
    $_SESSION['User'] = serialize($user);

?>
			<p>Your name has been changed. Please <a href="../">click here to return to your account page</a>.</p>
			<?php

} elseif (!empty($_SESSION['LoggedIn']) && !empty($_SESSION['User']))
{ //Form to input name information if logged in
    $user = unserialize($_SESSION['User']);

?>
			
			<form method="post" action="./" name="nameform" id="nameform">
			<fieldset>
				<label for="firstname">First name:</label><input type="text" name="firstname" id="firstname" value="<?=

    $user->getFirstName()

?>" /><br><br>
				<label for="lastname">Last name:</label><input type="text" name="lastname" id="lastname" value="<?=

    $user->getLastName()

?>" /><br><br>
				<input type="Submit" name="Submit" id="Submit" value="Submit" />
			</fieldset>
			</form>
			
			<?php

} else
{

?>
					
			   <p>You must login to view this page.</p>
									
			   <?php

}

?>
		</div>
		
		<?php

include_once ('../../footer.php')

?>
	</div>

</body>
</html>